package com.dongbo.recorder.screenrecord.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.dongbo.recorder.screenrecord.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * description：
 * author：lutengxuan
 * CreateDate：2020-05-07
 */
public class ToVipDialog extends Dialog {

    private OnDialogEventListener onDialogEventListener;
    private Context context;

    /**
     * @param context
     * @param themeResId
     * @param onDialogEventListener dialog 事件回调
     */
    public ToVipDialog(Context context,
                       int themeResId,
                       OnDialogEventListener onDialogEventListener) {
        super(context, themeResId);
        this.context = context;
        this.onDialogEventListener = onDialogEventListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_to_vip);
        ButterKnife.bind(this);

        Window window = getWindow();
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(layoutParams);
    }

    @OnClick({R.id.tv_to_vip, R.id.tv_to_gg, R.id.iv_icon_close})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_to_vip:
                if (onDialogEventListener != null) onDialogEventListener.onVipClicked();
                dismiss();
                break;
            case R.id.tv_to_gg:
                if (onDialogEventListener != null) onDialogEventListener.onGgClicked();
                dismiss();
                break;
            case R.id.iv_icon_close:
                dismiss();
                break;
        }
    }

    public interface OnDialogEventListener {
        void onVipClicked();

        void onGgClicked();
    }

    public void destroy() {
        onDialogEventListener = null;
        context = null;
        dismiss();
        cancel();
    }

}
